< previous page page_335 next page >

Page 335
0335-01.jpg
Figure 11.9
Program LeastSq fitting a line to a set of points.
You can then take the partial derivatives of this equation with respect to a, b, and c.
e10a6a0a59f035e870d90cca05b85fce.gif
dE/da = S 2 * (a * xi2 + b * xi + c - yi) * xi2
  = 2 * (a * S xi4 + b * S xi3 + c * S xi2 - S yi * xi2)
dE/db = S 2 * (a * xi2 + b * xi + c - yi) * xi
  = 2 * (a * S xi3 + b * S xi2 + c * S xi - S yi * xi)
dE/dc = S 2 * (a * xi2 + b * xi + c - yi)
  = 2 * (a * 
S xi2 + b * S xi + c * S 1 - S yi)
Once again, the values xi and yi values are just numbers, so you can compute the values of the summations. For convenience, let:
e10a6a0a59f035e870d90cca05b85fce.gif
A = S xi4
B = S xi3
C = S xi2
D = S yi * xi2
E = S xi
F = S yi * xi
G = S yi
Substituting these values into the partial derivatives, setting them equal to zero, and rearranging a bit gives you the three equations:
e10a6a0a59f035e870d90cca05b85fce.gif
a * A + b * B + c * C = D
a * B + b * C + c * E = F
a * C + b * E + c * N + G
You can now solve these three equations for the three unknowns a, b, and c to get:
e10a6a0a59f035e870d90cca05b85fce.gif
a = [(C * D - B * F) * (E2 - C * N) - (E * F - C * G) * (C2 - B * E)] /
[(A * C - B
2) * (E2 - C * N) + (C2 - B * E)2]

 
< previous page page_335 next page >